dist/PEinjector.7z: src/main.py src/log.py src/action.py src/hook.pyw src/makelnk.py src/regwrite.py src/config.py src/loader.py src/utils.py root/VentoyAutoRun.bat
ifeq ($(OS), Windows_NT)
	mkdir tmp\pkg\PEinjector\env
	mkdir tmp\pkg\PEinjector\src
	mkdir tmp\pkg\PEinjector\tool
	xcopy root .\tmp\pkg /C /Y /E
	xcopy env .\tmp\pkg\PEinjector\env /C /Y /E
	xcopy src .\tmp\pkg\PEinjector\src /C /Y /E
	xcopy tool .\tmp\pkg\PEinjector\tool /C /Y /E
	rmdir /S /Q dist
	mkdir dist
	7z a -t7z dist\PEinjector.7z .\tmp\pkg\PEinjector -r -m0=BCJ -m1=LZMA:d=21 -ms -mmt
	7z a -t7z dist\PEinjector.7z .\tmp\pkg\VentoyAutoRun.bat -m0=BCJ -m1=LZMA:d=21 -ms -mmt
	rmdir /S /Q tmp
else
	mkdir tmp/pkg/PEinjector/env -p
	mkdir tmp/pkg/PEinjector/src -p
	mkdir tmp/pkg/PEinjector/tool -p
	cp ./root/* ./tmp/pkg -rfp
	cp ./env ./tmp/pkg/PEinjector -rfp
	cp ./src ./tmp/pkg/PEinjector -rfp
	cp ./tool ./tmp/pkg/PEinjector -rfp
	rm -rf dist
	mkdir disk -p
	7z a -t7z dist/PEinjector.7z ./tmp/pkg/PEinjector -r -m0=BCJ -m1=LZMA:d=21 -ms -mmt
	7z a -t7z dist/PEinjector.7z ./tmp/pkg/VentoyAutoRun.bat -m0=BCJ -m1=LZMA:d=21 -ms -mmt
	rm -rf tmp
endif
tmp/py/python.zip:
ifeq ($(OS), Windows_NT)
	mkdir tmp\py 
	cd tmp\py
	wget https://registry.npmmirror.com/-/binary/python/3.12.1/python-3.12.1-embed-amd64.zip -O tmp\py/python.zip
else
	mkdir tmp/py -p
	cd tmp/py
	wget https://registry.npmmirror.com/-/binary/python/3.12.1/python-3.12.1-embed-amd64.zip -O tmp/py/python.zip
endif
env/python.exe: tmp/py/python.zip
	7z x -y -aos -oenv/ tmp/py/python.zip
install: dist/PEinjector.7z installer/install.py
ifeq ($(OS), Windows_NT)
	python installer/install.py
else
	sudo python installer/install.py
endif
build: dist/PEinjector.7z
prepare: env/python.exe
clean:
ifeq ($(OS), Windows_NT)
	rmdir /S /Q tmp
	rmdir /S /Q dist
	mkdir dist
else
	rm -rf tmp
	rm -rf dist
	mkdir dist -p
endif
debug: dist/PEinjector.7z
ifeq ($(OS), Windows_NT)
	python installer/install.py
	start_vm.cmd
else
	sudo python installer/install.py
	sudo start_vm.sh
endif
start:
ifeq ($(OS), Windows_NT)
	start_vm.cmd
else
	sudo start_vm.sh
endif
